package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.*;

import ejb.dto.ExcursionAvailabilityDTO;


/**
 * The persistent class for the excursion_availability database table.
 * 
 */
@Entity
@Table(name="excursion_availability", uniqueConstraints=@UniqueConstraint(columnNames={"EXCURSION_ID", "FROM_DATE", "TO_DATE"}))
@NamedQueries({
	@NamedQuery(name="ExcursionAvailability.findAll", query="SELECT e FROM ExcursionAvailability e"),
	@NamedQuery(name="ExcursionAvailability.findByExcursion", query="SELECT e FROM ExcursionAvailability e WHERE e.excursion = :ex")
})
public class ExcursionAvailability implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@Temporal(javax.persistence.TemporalType.TIMESTAMP)
	@Column(name="FROM_DATE")
	private Date fromDate;

	private int remaining;

	@Temporal(javax.persistence.TemporalType.TIMESTAMP)
	@Column(name="TO_DATE")
	private Date toDate;

	/**
	 * bi-directional many-to-one association to Excursion
	 */
	@ManyToOne
	private Excursion excursion;

	@OneToMany(mappedBy="excursionDates")
	private List<Reservation> reservations;
	
	//CONSTRUCTORS
	public ExcursionAvailability() {
	}
	
	public ExcursionAvailability(ExcursionAvailabilityDTO av, Excursion excursion){
		this.id = av.getId();
		this.fromDate = av.getFromDate();
		this.remaining = av.getRemaining();
		this.toDate = av.getToDate();
		this.excursion = excursion;
	}

	
	//GETTER AND SETTER
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getFromDate() {
		return this.fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public int getRemaining() {
		return this.remaining;
	}

	public void setRemaining(int remaining) {
		this.remaining = remaining;
	}

	public Date getToDate() {
		return this.toDate;
	}

	public void setToDate(Date toDate) {
		this.toDate = toDate;
	}

	public Excursion getExcursion() {
		return this.excursion;
	}

	public void setExcursion(Excursion excursion) {
		this.excursion = excursion;
	}

}